package com.ruoyi.bloom;

import org.springframework.stereotype.Service;
import com.google.common.hash.BloomFilter;

@Service
public class UserService {

    private final BloomFilter<Long> bloomFilter;

    public UserService(BloomFilter<Long> bloomFilter) {
        this.bloomFilter = bloomFilter;
    }

    // 添加元素到布隆过滤器
    public void addToBloomFilter(Long userId) {
        bloomFilter.put(userId);
    }

    // 判断元素是否存在（可能误判）
    public boolean mightContain(Long userId) {
        return bloomFilter.mightContain(userId);
    }
}
